#ifndef P_EVENT_OBSERVER_H
#define P_EVENT_OBSERVER_H

#include "PEventDispatcher.h"

namespace Piccolo
{
    class PEventObserver
    {
    public:
        PEventObserver() = default;
        ~PEventObserver()
        {
            PEventDispatcher::GetInstance()->DestroyObserver(this);
        }

        template<typename T>
        void OnEvent(const std::function<void(const T&)>& func)
        {
            PEventDispatcher::GetInstance()->AddObserverHandler(this, func);
        }
    };
}

#endif